package com.lhl;

import javax.imageio.ImageIO;
import javax.swing.*;
import java.awt.image.BufferedImage;
import java.awt.image.RenderedImage;
import java.io.File;
import java.io.IOException;
import java.net.URL;

/**
 * @className: GenImg
 * @description: TODO 类描述
 * @author: king
 * @date: 2020-10-13 15:57
 **/
public class GenImg {
    public static void main(String[] args) throws IOException {
        JEditorPane ed = new JEditorPane(new URL("http://172.18.10.71:4200/xundian/home"));
        ed.setSize(200,200);

        //create a new image
        BufferedImage image = new BufferedImage(ed.getWidth(), ed.getHeight(),
                BufferedImage.TYPE_INT_ARGB);

        //paint the editor onto the image
        SwingUtilities.paintComponent(image.createGraphics(),
                ed,
                new JPanel(),
                0, 0, image.getWidth(), image.getHeight());
        //save the image to file
        ImageIO.write((RenderedImage)image, "png", new File("C:\\dev\\javaDev\\html.png"));
        System.out.println("-----------------------------");
    }
}